package com.kfm.controller;

import com.kfm.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloController {

    @RequestMapping("/hello")
    public String sayHello() {
        return "hello";
    }

    @GetMapping("/ajax")
    public String ajax(){
        return "ajax";
    }

    @GetMapping("/chat")
    public ModelAndView chat(){
        return new ModelAndView("chat");
    }


    @PostMapping("/json")
    @ResponseBody
    public User json(@RequestBody User user){
        return user;
    }

    @PostMapping("/post")
    @ResponseBody
    public String post(@RequestBody String msg){
        return "成功发送了一个 post 请求" + msg;
    }

    @GetMapping("/get")
    @ResponseBody
    public String get() {
        return "this is a get";
    }
}
